package com.testing.vip12splogin.mapper;

import com.testing.vip12splogin.model.User;
import org.apache.ibatis.annotations.*;

/**
 * @Classname UserMapper
 * @Description 类型说明
 * @Date 2022/5/22 20:45
 * @Created by 特斯汀Roy
 */
@Mapper
public interface UserMapper {

    /**
     * 插入数据，方法提供信息，然后进行insert
     * 参数中@param的值和sql语句中的#{变量}对应就行。
     * @param username  映射到uName，方便insert语句#{uName}调用
     * @param password
     * @param nick
     * @param desc
     * @return
     */
    @Insert("insert into userinfo(id,username,`password`,nickname,`describe`) " +
            "values(0,#{uName},#{pwd},#{nick},#{desc})")
    int insertUser(@Param("uName") String username,
                   @Param("pwd") String password,
                   @Param("nick") String nick,
                   @Param("desc") String desc);

    @Delete("delete from userinfo where username=#{uName}")
    int deleteUser(@Param("uName") String username);

    @Update("update userinfo set nickname=#{nick} where username=#{uname}")
    int updateNickNameByUserName(@Param("uname")String u, @Param("nick")String nickname);

    @Select("select * from userinfo where username=#{uname}")
    User queryUserByName(@Param("uname") String uname);

    @Select("select * from userinfo where username=#{uname} and `password`=#{pwd}")
    User queryUserByNameAndPwd(@Param("uname") String uname,@Param("pwd")String pwd);


}
